<template>
  <div class="user-container">
    <div class="header"></div>
    <!-- 内容开始 -->
    <div class="content" id="table">
      <!-- 内容盒子 必须要有content类名 和 table id名 -->
      <el-table :data="tableData" height="100%" style="width: 100%">
        <el-table-column
          prop="date"
          :label="`${total}条`"
          width="60"
          fixed
          type="index"
        />
        <el-table-column prop="date" label="日期"> </el-table-column>
        <el-table-column prop="name" label="姓名"> </el-table-column>
        <el-table-column prop="address" label="地址"> </el-table-column>
        <el-table-column prop="date" label="日期"> </el-table-column>
        <el-table-column prop="name" label="姓名"> </el-table-column>
        <el-table-column prop="address" label="地址"> </el-table-column>
        <el-table-column prop="date" label="日期"> </el-table-column>
        <el-table-column prop="name" label="姓名"> </el-table-column>
        <el-table-column prop="address" label="地址"> </el-table-column>
      </el-table>
      <div class="pagination">
        <el-pagination
          :page-size="pageSize"
          layout="prev, pager, next, jumper"
          :total="total"
          @current-change="(params) => ((pageNo = params), findList())"
        />
      </div>
    </div>
    <!-- 内容结束 -->
  </div>
</template>

<script>
export default {
  name: "",
  components: {},
  props: {},
  data() {
    return {
      tableData: [
        {
          date: "2016-05-02",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1518 弄",
        },
        {
          date: "2016-05-04",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1517 弄",
        },
        {
          date: "2016-05-01",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1519 弄",
        },
        {
          date: "2016-05-03",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1516 弄",
        },
        {
          date: "2016-05-02",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1518 弄",
        },
        {
          date: "2016-05-04",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1517 弄",
        },
        {
          date: "2016-05-01",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1519 弄",
        },
        {
          date: "2016-05-03",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1516 弄",
        },
        {
          date: "2016-05-02",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1518 弄",
        },
        {
          date: "2016-05-04",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1517 弄",
        },
        {
          date: "2016-05-01",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1519 弄",
        },
        {
          date: "2016-05-03",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1516 弄",
        },
        {
          date: "2016-05-02",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1518 弄",
        },
        {
          date: "2016-05-04",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1517 弄",
        },
      ],
      total: 10,
      pageSize: 10,
      pageNo: 1,
    };
  },
  computed: {},
  watch: {},
  created() {},
  mounted() {
    let height;
    let Table = document.getElementById("table");
    this.$erd.listenTo(document.getElementsByClassName("header"), (element) => {
      height = element.offsetHeight;
    });
    this.$erd.listenTo(document.getElementsByTagName("body"), (element) => {
      this.$nextTick(() => {
        Table.style.height = element.offsetHeight - (104 + height) + "px";
      });
    });
  },
  beforeDestroy() {
    // 离开页面删除检测器和所有侦听器
    this.$erd.uninstall(document.getElementsByTagName("body")); // 这里用ref是因为vue离开页面后获取不到dom
  },
  methods: {
    handleCurrentChange() {},
  },
};
</script>

<style scoped lang="scss">
.user-container {
  height: 100%;
}
.header {
  display: flex;
  flex-wrap: wrap;

  div {
    padding: 5px 10px;
  }

  .btn {
    display: flex;
    flex-grow: 1;
    justify-content: space-between;
  }
}
</style>
